package com.example.lenovo.myapplication.pojo;

import android.os.Parcel;
import android.os.Parcelable;

public class Sensor {
    //定义一个名字
    private String sensorName;
    //单位
    private String dataUnit;
    //值
    private Double data;
    //获取名字的方法
    public String getSensorName(){
        return sensorName;
    }
    //设置名字的方法
    public void setSensorName(String sensorName){
        this.sensorName=sensorName;
    }

    public String getDataUnit (){
        return dataUnit;
    }

    public void setDataUnit (String dataUnit) {
        this.dataUnit=dataUnit;
    }

    public Double getData (){
        return data;
    }

    public void setData (double data) {
        this.data=data;
    }

    //实例化对象的时候就可以传入相关数据
    public Sensor(String sensorName,String dataUnit,Double data){
        this.sensorName=sensorName;
        this.dataUnit=dataUnit;
        this.data=data;
    }

    protected Sensor (Parcel in) {
        sensorName=in.readString();
        dataUnit=in.readString();
        data=in.readDouble();
    }

    public static final Parcelable.Creator<Sensor> CREATOR=new Parcelable.Creator<Sensor>() {
        @Override
        public Sensor createFromParcel(Parcel source) {
            return new Sensor(source);
        }

        @Override
        public Sensor[] newArray(int size) {
            return new Sensor[size];
        }
    };
}
